Page({
  data: {
    isCounting: false, 
    countDown: 60,    
    timer: null        
  },

  startCountDown() {
   
    if (this.data.isCounting) return;

    
    this.setData({
      isCounting: true,
      countDown: 60
    });

    const timer = setInterval(() => {
      let { countDown } = this.data;
      countDown--;

      if (countDown > 0) {
  
        this.setData({ countDown });
      } else {
   
        clearInterval(timer);
        this.setData({
          isCounting: false,
          countDown: 60
        });
      }
    }, 1000);

    this.setData({ timer });
  },


  onUnload() {
    clearInterval(this.data.timer);
  }
});